/**
 * Pangolin IM Server
 * autor:   yiyefangzhou24
 * email:   yiyefangzhou24@qq.com
 * data:    21/10/1
 */
#ifndef PANGOLINSERVER_FUNCTION_H
#define PANGOLINSERVER_FUNCTION_H

#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include "db_mysql.h"
#include "md5.h"
#include "db_redis.h"
#include "log.h"
#include "package.h"
#include "base64.h"

#define IN_USERNAME     1000
#define IN_PASSWD       1001
#define IN_UID          1002
#define IN_OS           1003
#define IN_KEY          1004
#define IN_TYPE         1005
#define IN_CONTEXT      1006
#define IN_PUBKEY       1007
#define IN_RESULT       1008
#define IN_HEADIMG      1009
#define IN_MID          1010

void system_init();
void _random_string(char * buff, int n);
bool _check_userkey(int uid , char * key);
bool _insert_userinfo(int uid , char * key , int fd);
bool _check_userlogin(int uid , char * passwd);
bool _response_register(char * username , char * passwd , int * uid);
bool _response_findfriend(int uid , char * username , char * headimg);
bool _response_logout(int uid);
int _check_friend(int fromuid , int touid);
bool _check_useronline(int uid);
void _string_md5encrypt(char * src , char *dst);
void _file_md5encrypt(char * src , char *dst);
bool _check_input(int type , void * src);
bool _response_repass(int uid , char * newpasswd);
bool _response_updateuserinfo(int uid , char * username , char * headimg);
bool _update_usertime(int uid);
bool _response_removeclient(int fd);
bool _push_msg_queue(int fromuid , int touid , char * msg , int cmd);
bool _add_friendlist(int from , int to , int remark);
bool _update_friendlist(int from , int to , int remark);
bool _del_friendlist(int from , int to);
//int _get_msg_queue_num(int uid);
int _pull_msg_queue(int uid , char msg[20][PACKAGE_BUFF_MAX_LEN]);
int _get_friendlist(int uid , int * uid_list , char ** name_list , char ** headimg_list);
int _count_friendlistbyuid(int uid);

#endif //PANGOLINSERVER_FUNCTION_H